let express = require('express')
let path = require('path')
let mysql = require('./api/sql')

let app = express()

app.use(express.static('./'))

// 模板类型
app.set('view engine', 'ejs');
// 模板文件目录
app.set('views', path.join(__dirname, './api/template'));

// 服务器渲染
app.post('/userList', async (req, res) => {
    let row = await mysql.query(`select * from user`);

    res.render('userlist', { msg: '你好吗', list: row })
})


app.listen(3000, () => {
    console.log('running port is 3000');
})